package edu.ubb.scrumster.model.model;

import java.util.List;

public class User implements AbstractModel{
	int id;
	String username;
	String password;
	String firstName;
	String lastName;
	String email;
	Organization organization;
	Scrum scrum;
	String type;
	
	List<Task> currentTasks;
	List<Project> history;

	public User(String username, String password, String firstName,
			String lastName, String email, Organization organization, Scrum scrum,
			String type) {
		super();
		this.username = username;
		this.password = password;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.organization = organization;
		this.scrum = scrum;
		this.type = type;
	}

	public User(int id, String username, String password, String firstName,
			String lastName, String email, Organization organization, Scrum scrum,
			String type) {
		super();
		this.id = id;
		this.username = username;
		this.password = password;
		this.firstName = firstName;
		this.lastName = lastName;
		this.email = email;
		this.organization = organization;
		this.scrum = scrum;
		this.type = type;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public Organization getOrganization() {
		return organization;
	}

	public void setOrganization(Organization organization) {
		this.organization = organization;
	}

	public Scrum getScrum() {
		return scrum;
	}

	public void setScrum(Scrum scrum) {
		this.scrum = scrum;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public List<Task> getCurrentTasks() {
		return currentTasks;
	}

	public void setCurrentTasks(List<Task> currentTasks) {
		this.currentTasks = currentTasks;
	}

	public List<Project> getHistory() {
		return history;
	}

	public void setHistory(List<Project> history) {
		this.history = history;
	}
	
	public String getObjectType(){
		return "User";
	}
	
	public void validate() throws ModelException{
		if (this.firstName.equals("") || this.firstName.isEmpty()){
			throw new ModelException("The first name is empty");
		}
		if (this.lastName.equals("") || this.lastName.isEmpty()){
			throw new ModelException("The first name is empty");
		}
		if (this.username.equals("") || this.username.isEmpty()){
			throw new ModelException("The first name is empty");
		}
		if (this.password.equals("") || this.password.isEmpty()){
			throw new ModelException("The first name is empty");
		}
		if (this.username.length()<6){
			throw new ModelException("The username is less than 6 characters.");
		}
		if (this.username.length()<8){
			throw new ModelException("The password is less than 8 characters.");
		}
	}
}
